// -----------------------------------------------
// Author:     code34 nicolas_boiteux@yahoo.fr
// Edited by:  Neumatic
// Warcontext: Steal an object
// -----------------------------------------------

private ["_find","_unit","_enemy","_missioncomplete"];

_unit = _this select 0;

_unit allowDammage false;
_missioncomplete = false;

while {!_missioncomplete} do {
	sleep 1;
	if (wcalert > 99) then {
		wcmessageW = [localize "STR_WC_MESSAGEMISSIONFAILED", localize "STR_WC_MESSAGELEAVEZONE"];
		["wcmessageW", "client"] call WC_fnc_publicvariable;
		wcmissionsuccess = true;
		_missioncomplete = true;
	};

	_enemy = nearestObjects [_unit, ["All"], 2];
	_find = false;
	{
		if (isPlayer _x) then {
			_find = true;
		};
	} foreach _enemy;

	if (_find) then {
		wcmessageW = [localize "STR_WC_MESSAGEMISSIONCOMPLETED", localize "STR_WC_MESSAGELEAVEZONE"];
		["wcmessageW", "client"] call WC_fnc_publicvariable;
		wcmissionsuccess = true;
		_missioncomplete = true;
		wcleveltoadd = 1;
	};
};

sleep 4;

deleteVehicle _unit;
